package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.DZfunds;
import com.hbnu.system.service.DZfundsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/DZfunds")
@Api(tags = "横向到账经费相关模块")
public class DZfundsController {
    @Autowired
    DZfundsService dZfundsService;

    @ApiOperation("到账经费添加")
    @PostMapping("/addDZfunds")
    public Rest<Boolean> AddDZfunds(@RequestBody DZfunds dZfunds){
        boolean add = dZfundsService.addDZfundsProject(dZfunds);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("到账经费删除")
    @GetMapping("/removeDZfunds")
    public Rest<Boolean> RemoveDZfunds(String id){
        boolean remove= dZfundsService.removeDZfundsProject(id);
        return remove ? Rest.success() : Rest.failed();
    }
    @ApiOperation("到账经费更新")
    @PostMapping("/UpdateDZfunds")
    public Rest<Boolean> UpdateDZfunds(@RequestBody DZfunds dZfunds){
        boolean update = dZfundsService.updateDZfundsProject(dZfunds);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("到账经费-通过横向项目id查询")
    @GetMapping("/GetDzfundsByTranprojectID")
    public Rest<List<DZfunds>> GetDZfundsByTranprojectID(String tranID){
        List<DZfunds> paperProjectByPaperID = dZfundsService.getDZfundsByTranprojectID(tranID);
        return Rest.success(paperProjectByPaperID);
    }
}
